/*
SteelNzb
Copyright (C) 2008  Wessel v. Staal

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef SOCKET_INCLUDED
#define SOCKET_INCLUDED

int socket_connect(const char * host, int port);
int socket_receive(int socket, char* buffer, int* size, int timeout);
int socket_send(int socket, char* buffer, unsigned int size);
char* socket_receiveLine(int socket, void* buf, int* size, int timeout);
int socket_waitForData(int socket);
char* socket_emptyBuffer(void* buf, int* size);
void socket_freeBuffer(void* buf);
void* socket_createBuffer();

#define MAX_RECEIVELINE_BUFFER 10000
#define MAX_PACKET_SIZE 1024
#define RECEIVE_TIMEOUT 10 /* seconds before receive call times out */

#define GENERAL_SOCKET_ERROR -1 /* general socket error */

#define SOCKET_ERROR_TIMEOUT -2 /* timeout */
#define SEND_ERROR -1 /* general send error */

#endif
